//Created by MyEclipse Struts
// XSL source (default): platform:/plugin/com.genuitec.eclipse.cross.easystruts.eclipse_4.1.1/xslt/JavaClass.xsl

package fms.web.action;

import fms.common.FieldInfo;
import fms.services.FieldService;
import fms.services.ServiceException;
import fms.services.ServiceManager;
import fms.web.form.AddfieldinfoForm;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

/** 
 * MyEclipse Struts
 * Creation date: 11-27-2006
 * 
 * XDoclet definition:
 * @struts.action path="/updatefieldinfo" name="AddfieldinfoForm" scope="request" validate="true"
 * @struts.action-forward name="updatefieldinfosucess" path="/updatefieldinfosucess.jsp"
 * @struts.action-forward name="updatefieldinfofail" path="/updatefieldinfofail.jsp"
 */
public class UpdatefieldinfoAction extends Action {

	// --------------------------------------------------------- Instance Variables

	// --------------------------------------------------------- Methods

	/** 
	 * Method execute
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 */
	public ActionForward execute(
		ActionMapping mapping,
		ActionForm form,
		HttpServletRequest request,
		HttpServletResponse response) {
		
		// TODO Auto-generated method stub
		String updatefieldid=(String)request.getParameter("field_id");

		
		 
		FieldInfo fieldinfo = new FieldInfo();
		String field_id = (String)fieldinfo.getFieldId();
		int field_type = (int)fieldinfo.getFieldType();
		int field_capacity = (int)fieldinfo.getFieldCapacity();
		double field_price = (double)fieldinfo.getFieldPrice();
		String field_status = (String)fieldinfo.getFieldStatus();
		
		fieldinfo.setFieldId(updatefieldid);
		
		FieldService service = null;
		try {
			service = (FieldService) ServiceManager.getDefaultManager()
					.getService(FieldService.class);
		} catch (ServiceException e) {

			e.printStackTrace();
		}
		fieldinfo.setFieldId(field_id);
		fieldinfo.setFieldType(field_type);
		fieldinfo.setFieldCapacity(field_capacity);
		fieldinfo.setFieldPrice(field_price);
		fieldinfo.setFieldStatus(field_status);
		
		//System.out.print(fieldinfo.getFieldId());
		try {
			service.updateField(fieldinfo.getFieldId(),fieldinfo.getFieldCapacity(),fieldinfo.getFieldType(),fieldinfo.getFieldPrice(),"used");
		} catch (ServiceException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return mapping.findForward("updatefieldinfosucess");
	
	}

}

